package com.jsmy.softapp.fragment;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.jsmy.softapp.R;
import com.jsmy.softapp.adapter.FragmentAdapter;
import com.jsmy.softapp.aroute.AR;
import com.jsmy.softapp.presenter.BusinessPresenter;
import com.jsmy.softapp.view.BusinessView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created with Android Studio.
 * User: wei_cd.
 * Date: 2018/4/17.
 * Time: 17:48.
 * To change for file | settings | file and code templates.
 */
@Route(path = AR.F_BUSINESS)
public class BusinessFragment extends BaseFragment<BusinessView, BusinessPresenter> implements BusinessView {


    @BindView(R.id.m_viewpage)
    ViewPager mViewpage;
    @BindView(R.id.m_tab)
    TabLayout mTab;
    FragmentAdapter adapter;
    List<Fragment> fragments;
    List<String> list;


    @Override
    protected BusinessPresenter createPresenter() {
        return new BusinessPresenter();
    }

    @Override
    protected int setView() {
        return R.layout.fragment_business;
    }

    @Override
    protected void init(View view) {
        fragments = new ArrayList<>();
        fragments.add(FragmentSmanager.getInstance().getFragment(FragmentSmanager.PLANT));
        fragments.add(FragmentSmanager.getInstance().getFragment(FragmentSmanager.DAILY));
        list = new ArrayList<>();
        list.add("沟通计划");
        list.add("沟通日志");

        mTab.setTabMode(TabLayout.MODE_FIXED);
        adapter = new FragmentAdapter(getChildFragmentManager(), fragments, list);
        mViewpage.setAdapter(adapter);
        mViewpage.setOffscreenPageLimit(2);
        mTab.setupWithViewPager(mViewpage);

    }

    @Override
    protected void initData(Bundle savedInstanceState) {

    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showLoadingData(String type, Object object) {

    }

    @Override
    public void onDestroyView() {
        presenter.model.disposable.clear();
        super.onDestroyView();
    }

    @Override
    public void updata() {

    }
}
